package ecoiot.com.testproject;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.db.chart.model.LineSet;
import com.db.chart.model.Point;
import com.db.chart.view.LineChartView;

import org.xclcharts.renderer.XEnum;
import org.xclcharts.renderer.info.AnchorDataPoint;

public class MainActivity extends AppCompatActivity {
    private LineChartView chartView;

//    private MySubscribe subscriber;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_william_chart);

        chartView = (LineChartView) findViewById(R.id.main_chart_view);

        LineSet lineSet = new LineSet();

        lineSet.addPoint(new Point("a",10.3f));
        lineSet.addPoint(new Point("b",28.2f));
        lineSet.addPoint(new Point("c",33.6f));
        lineSet.addPoint(new Point("d",41.8f));
        lineSet.addPoint(new Point("e",48.9f));
        lineSet.addPoint(new Point("f",55.3f));
        lineSet.addPoint(new Point("g",63.7f));
        lineSet.addPoint(new Point("h",77.3f));

        lineSet.setDotsRadius(1);

        lineSet.setThickness(5);
        lineSet.setColor(Color.BLUE);

        lineSet.setFill(Color.GRAY);
        lineSet.setSmooth(true);


        chartView.addData(lineSet);

        AnchorDataPoint an4 = new AnchorDataPoint(0,2, XEnum.AnchorStyle.TOBOTTOM);
        an4.setBgColor(Color.WHITE);
        an4.setLineWidth(15);
        an4.setLineStyle(XEnum.LineStyle.DOT);
        an4.setAnchorStyle(XEnum.AnchorStyle.RECT);


       /* subscriber = new MySubscribe();

        Observable.create(new Observable.OnSubscribe<String>() {
            @Override
            public void call(Subscriber<? super String> subscriber) {
                long j = 0;

               for (long i  = 0 ; i < 50000000; i ++) {
                   j ++ ;
               }

                subscriber.onNext("");
            }
        })
                .compose(this.<String>bindToLifecycle())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);

        BehaviorSubject<Object> lifecycleSubject = BehaviorSubject.create();
*/





    }

   /* private class MySubscribe extends Subscriber {

        @Override
        public void onCompleted() {

        }

        @Override
        public void onError(Throwable e) {

        }

        @Override
        public void onNext(Object o) {
            Log.e("error","onNext");
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("error","onDestroy");
    }*/
}
